package com.ninetaildemonfox.zdl.socialproject.utils;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.ninetaildemonfox.zdl.ninetaildemonfox.base.BaseApplication;
import com.ninetaildemonfox.zdl.socialproject.R;
import com.ninetaildemonfox.zdl.socialproject.SpApplication;

/**
 * 创建人： Nine tails fox
 * 创建时间： 2019/8/12
 * 功能描述：
 * 联系方式：1037438704@qq.com
 *
 * @author NineTailDemonFox
 */

public class GlideUtils {
    /**
     * 加载圆角图片
     */
    public static void glideFille(Context context, String url, ImageView imageView) {
        RoundedCorners roundedCorners = new RoundedCorners(10);
        //通过RequestOptions扩展功能,override:采样率,因为ImageView就这么大,可以压缩图片,降低内存消耗
        RequestOptions options = RequestOptions
                .bitmapTransform(roundedCorners)
                .placeholder(R.mipmap.icon_head_moren)
                .error(R.mipmap.icon_head_moren);
        Glide.with(SpApplication.getInstance()).load(url).apply(options).into(imageView);
    }
//    public static void glideFille(Context context, String url, ImageView imageView) {
//        Glide.with(context).load(url).apply(new RequestOptions().placeholder(R.mipmap.icon_head_moren)
//                .error(R.mipmap.icon_head_moren)).into(imageView);
//    }

    public static void glideFille(Context context, int url, ImageView imageView) {
        Glide.with(context).load(url).apply(new RequestOptions().placeholder(R.mipmap.icon_head_moren)
                .error(R.mipmap.icon_head_moren)).into(imageView);
    }

    public static void glideCircle(Context context, int url, ImageView imageView) {
        Glide.with(context).load(url).apply(new RequestOptions().circleCrop()
                .placeholder(R.mipmap.icon_head_moren)
                .error(R.mipmap.icon_head_moren))
                .into(imageView);
    }

    public static void glideCircle(Context context, String url, ImageView imageView) {
        Glide.with(context).load(url).apply(new RequestOptions()
                .circleCrop()
                .placeholder(R.mipmap.icon_head_moren)
                .error(R.mipmap.icon_head_moren)).into(imageView);
    }

    public static void originalGraph(Context context, String url, ImageView imageView) {
        Glide.with(context).load(url).apply(new RequestOptions()
                .placeholder(R.mipmap.icon_head_moren)
                .error(R.mipmap.icon_head_moren)).into(imageView);
    }

}